// 
//  Copyright (C) 2009 Jacek Trubłajewicz
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 

using System;
using System.Drawing;
using HAKGERSoft;
using Mono.Unix;
using NLog;

namespace wxGadu
{	
	/// <summary>
	/// Panel used of <c>ConfigurationDialog</c>,
	/// keeps options related to application look
	/// </summary>
	public class AppearanceSettingsPanel : wx.Panel
	{
		
		#region Id
		public enum Id
		{
			contactListBgButton = 1331,
			infoPanelBgButton,
			contactListFontButton,
			infoPanelFontButton,
			topChatFontButton,
			chatEntryFontButton,
			contactListBgTC,
			infoPanelBgTC,
			contactListFontTC,
			infoPanelFontTC,
			topChatFontTC,
			chatEntryFontTC,
			contactListBgCheck,
			infoPanelBgCheck,
			contactListFontCheck,
			infoPanelFontCheck,
			topWindowFontCheck,
			chatEntryFontCheck,
			mainWidthSpin,
			mainHeightSpin,
			chatWidthSpin,
			chatHeightSpin
		}
		#endregion
		
		#region controls
		private wx.StaticText mainWidthST;
		private wx.StaticText mainHeightST;
		private wx.StaticText chatWidthST;
		private wx.StaticText chatHeightST;
		private wx.Button contactListBgButton;
		private wx.Button infoPanelBgButton;
		private wx.Button contactListFontButton;
		private wx.Button infoPanelFontButton;
		private wx.Button topChatFontButton;
		private wx.Button chatEntryFontButton;
		private wx.TextCtrl contactListBgTC;
		private wx.TextCtrl infoPanelBgTC;
		private wx.TextCtrl contactListFontTC;
		private wx.TextCtrl infoPanelFontTC;
		private wx.TextCtrl topChatFontTC;
		private wx.TextCtrl chatEntryFontTC;
		private wx.CheckBox contactListBgCheck;
		private wx.CheckBox infoPanelBgCheck;
		private wx.CheckBox contactListFontCheck;
		private wx.CheckBox infoPanelFontCheck;
		private wx.CheckBox topChatFontCheck;
		private wx.CheckBox chatEntryFontCheck;
		private wx.SpinCtrl mainWidthSpin;
		private wx.SpinCtrl mainHeightSpin;
		private wx.SpinCtrl chatWidthSpin;
		private wx.SpinCtrl chatHeightSpin;
		private wx.StaticBox contactListBgBox;
		private wx.StaticBox infoPanelBgBox;
		private wx.StaticBox contactListFontBox;
		private wx.StaticBox infoPanelFontBox;
		private wx.StaticBox topChatFontBox;
		private wx.StaticBox chatEntryFontBox;
		private wx.StaticBox mainWindowBox;
		private wx.StaticBox chatWindowBox;
		private wx.StaticBox colourBox;
		private wx.StaticBox fontBox;
		private wx.StaticBox sizeBox;
		#endregion
		
		#region sizers
		private wx.BoxSizer topSizer;
		private wx.BoxSizer boxSizer;
		private wx.StaticBoxSizer colourSizer;
		private wx.StaticBoxSizer fontSizer;
		private wx.StaticBoxSizer sizeSizer;
		private wx.StaticBoxSizer contactListBgSizer;
		private wx.StaticBoxSizer infoPanelBgSizer;
		private wx.StaticBoxSizer contactListFontSizer;
		private wx.StaticBoxSizer infoPanelFontSizer;
		private wx.StaticBoxSizer topChatFontSizer;
		private wx.StaticBoxSizer chatEntryFontSizer;
		private wx.StaticBoxSizer mainWindowSizer;
		private wx.StaticBoxSizer chatWindowSizer;
		private wx.FlexGridSizer mainWindowGrid;
		private wx.FlexGridSizer chatWindowGrid;
		#endregion
		
		#region data members
#if LOG
		private Logger logger = LogManager.GetCurrentClassLogger();	
#endif
		private Colour contactListBgColor;
		private Colour infoPanelBgColor;
		private Font contactListFont;
		private Font infoPanelFont;
		private Font topChatFont;
		private Font chatEntryFont;
		#endregion
		
		/// <summary>
		/// Ctor
		/// </summary>
		/// <param name="parent">
		/// A <see cref="wx.Window"/>
		/// </param>
		/// <param name="id">
		/// A <see cref="System.Int32"/>
		/// </param>
		/// <param name="pos">
		/// A <see cref="Point"/>
		/// </param>
		/// <param name="size">
		/// A <see cref="Size"/>
		/// </param>
		/// <param name="style">
		/// A <see cref="System.UInt32"/>
		/// </param>
		public AppearanceSettingsPanel(wx.Window parent, int id, Point pos, Size size, uint style):
			base(parent, id, pos, size, style)
		{
			DoControls();
			DoControlsProperties();
			DoLayout();
			
			EVT_UPDATE_UI((int) Id.contactListBgButton, new wx.EventListener(OnContactListBgButtonUI));
			EVT_UPDATE_UI((int) Id.infoPanelBgButton, new wx.EventListener(OnInfoPanelBgButtonUI));
			EVT_UPDATE_UI((int) Id.contactListFontButton, new wx.EventListener(OnContactListFontButtonUI));
			EVT_UPDATE_UI((int) Id.infoPanelFontButton, new wx.EventListener(OnInfoPanelFontButtonUI));
			EVT_UPDATE_UI((int) Id.topChatFontButton, new wx.EventListener(OnTopChatFontButtonUI));
			EVT_UPDATE_UI((int) Id.chatEntryFontButton, new wx.EventListener(OnChatEntryFontButtonUI));
//			EVT_UPDATE_UI((int) Id.contactListBgTC, new wx.EventListener(OnContactListBgTCUI));
			EVT_UPDATE_UI((int) Id.contactListFontTC, new wx.EventListener(OnContactListFontTCUI));
			EVT_UPDATE_UI((int) Id.infoPanelFontTC, new wx.EventListener(OnInfoPanelFontTCUI));
			EVT_UPDATE_UI((int) Id.topChatFontTC, new wx.EventListener(OnTopChatFontTCUI));
			EVT_UPDATE_UI((int) Id.chatEntryFontTC, new wx.EventListener(OnChatEntryFontTCUI));
			
			EVT_BUTTON((int) Id.contactListBgButton, new wx.EventListener(OnContactListBgButton));
			EVT_BUTTON((int) Id.infoPanelBgButton, new wx.EventListener(OnInfoPanelBgButton));
			EVT_BUTTON((int) Id.contactListFontButton, new wx.EventListener(OnContactListFontButton));
			EVT_BUTTON((int) Id.infoPanelFontButton, new wx.EventListener(OnInfoPanelFontButton));
			EVT_BUTTON((int) Id.topChatFontButton, new wx.EventListener(OnTopChatFontButton));
			EVT_BUTTON((int) Id.chatEntryFontButton, new wx.EventListener(OnChatEntryFontButton));
			
		}
		
		private void DoControls()
		{
			mainWidthST = new wx.StaticText(this, Catalog.GetString("Width:"));
			mainHeightST = new wx.StaticText(this, Catalog.GetString("Height:"));
			chatWidthST = new wx.StaticText(this, Catalog.GetString("Width:"));
			chatHeightST = new wx.StaticText(this, Catalog.GetString("Height:"));
			contactListBgButton = new wx.Button(this, (int) Id.contactListBgButton, Catalog.GetString("Select"));
			infoPanelBgButton = new wx.Button(this, (int) Id.infoPanelBgButton, Catalog.GetString("Select"));
			contactListFontButton = new wx.Button(this, (int) Id.contactListFontButton, Catalog.GetString("Select"));
			infoPanelFontButton = new wx.Button(this, (int) Id.infoPanelFontButton, Catalog.GetString("Select"));
			topChatFontButton = new wx.Button(this, (int) Id.topChatFontButton, Catalog.GetString("Select"));
			chatEntryFontButton = new wx.Button(this, (int) Id.chatEntryFontButton, Catalog.GetString("Select"));
			contactListBgTC = new wx.TextCtrl(this, (int) Id.contactListBgTC, string.Empty,
			                                  wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                  wx.TextCtrl.wxTE_READONLY|wx.Window.wxNO_BORDER);
			infoPanelBgTC = new wx.TextCtrl(this, (int) Id.infoPanelBgTC, string.Empty,
			                                  wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                  wx.TextCtrl.wxTE_READONLY|wx.Window.wxNO_BORDER);
			contactListFontTC = new wx.TextCtrl(this, (int) Id.contactListFontTC, string.Empty,
			                                  wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                  wx.TextCtrl.wxTE_READONLY);
			infoPanelFontTC = new wx.TextCtrl(this, (int) Id.infoPanelFontTC, string.Empty,
			                                  wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                  wx.TextCtrl.wxTE_READONLY);
			topChatFontTC = new wx.TextCtrl(this, (int) Id.topChatFontTC, string.Empty,
			                                  wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                  wx.TextCtrl.wxTE_READONLY);
			chatEntryFontTC = new wx.TextCtrl(this, (int) Id.chatEntryFontTC, string.Empty,
			                                  wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                  wx.TextCtrl.wxTE_READONLY);
			contactListBgCheck = new wx.CheckBox(this, (int) Id.contactListBgCheck, Catalog.GetString("Use default color:"), 
			                                     wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                     wx.Alignment.wxALIGN_RIGHT);
			infoPanelBgCheck = new wx.CheckBox(this, (int) Id.infoPanelBgCheck, Catalog.GetString("Use default color:"), 
			                                     wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                     wx.Alignment.wxALIGN_RIGHT);
			contactListFontCheck = new wx.CheckBox(this, (int) Id.contactListFontCheck, Catalog.GetString("Use default font:"), 
			                                     wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                     wx.Alignment.wxALIGN_RIGHT);
			infoPanelFontCheck = new wx.CheckBox(this, (int) Id.infoPanelFontCheck, Catalog.GetString("Use default font:"), 
			                                     wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                     wx.Alignment.wxALIGN_RIGHT);
			topChatFontCheck = new wx.CheckBox(this, (int) Id.topWindowFontCheck, Catalog.GetString("Use default font:"), 
			                                     wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                     wx.Alignment.wxALIGN_RIGHT);
			chatEntryFontCheck = new wx.CheckBox(this, (int) Id.chatEntryFontCheck, Catalog.GetString("Use default font:"), 
			                                     wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                     wx.Alignment.wxALIGN_RIGHT);
			wx.Display disp = wx.Display.GetDisplay(0);
			mainWidthSpin = new wx.SpinCtrl(this, (int) Id.mainWidthSpin, string.Empty, 
			                                wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                0, 200, disp.Geometry.Width, 0);
			mainHeightSpin = new wx.SpinCtrl(this, (int) Id.mainHeightSpin, string.Empty, 
			                                wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                0, 390, disp.Geometry.Height, 0);
			chatWidthSpin = new wx.SpinCtrl(this, (int) Id.chatWidthSpin, string.Empty, 
			                                wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                0, 280, disp.Geometry.Width, 0);
			chatHeightSpin = new wx.SpinCtrl(this, (int) Id.chatHeightSpin, string.Empty, 
			                                wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
			                                0, 317, disp.Geometry.Height, 0);
			contactListBgBox = new wx.StaticBox(this, Catalog.GetString("Contact list background:"));
			infoPanelBgBox = new wx.StaticBox(this, Catalog.GetString("Info panel background:"));
			contactListFontBox = new wx.StaticBox(this, Catalog.GetString("Contact List:"));
			infoPanelFontBox = new wx.StaticBox(this, Catalog.GetString("Info panel:"));
			topChatFontBox = new wx.StaticBox(this, Catalog.GetString("Top chat window:"));
			chatEntryFontBox = new wx.StaticBox(this, Catalog.GetString("Chat entry field:"));
			mainWindowBox = new wx.StaticBox(this, Catalog.GetString("Main window:"));
			chatWindowBox = new wx.StaticBox(this, Catalog.GetString("Chat window:"));
			colourBox = new wx.StaticBox(this, Catalog.GetString("Colour:"));
			fontBox = new wx.StaticBox(this, Catalog.GetString("Font:"));
			sizeBox = new wx.StaticBox(this, Catalog.GetString("Size:"));
		}
		
		public void DoControlsProperties()
		{
			contactListBgTC.Enable(false);
			infoPanelBgTC.Enable(false);
		}
		
		public void DoLayout()
		{
			topSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
			{
				boxSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
				{
					colourSizer = new wx.StaticBoxSizer(colourBox, wx.Orientation.wxVERTICAL);
					{
						contactListBgSizer = new wx.StaticBoxSizer(contactListBgBox, wx.Orientation.wxHORIZONTAL);
						{
							contactListBgSizer.Add(contactListBgCheck, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							contactListBgSizer.Add(20, 20, 0, 0, 0);
							contactListBgSizer.Add(contactListBgButton, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							contactListBgSizer.Add(20, 20, 0, 0, 0);
							contactListBgSizer.Add(contactListBgTC, 1, wx.Alignment.wxALIGN_CENTER_VERTICAL);
						}
						colourSizer.Add(contactListBgSizer, 0, wx.Stretch.wxEXPAND);

						infoPanelBgSizer = new wx.StaticBoxSizer(infoPanelBgBox, wx.Orientation.wxHORIZONTAL);
						{
							infoPanelBgSizer.Add(infoPanelBgCheck, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							infoPanelBgSizer.Add(20, 20, 0, 0, 0);
							infoPanelBgSizer.Add(infoPanelBgButton, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							infoPanelBgSizer.Add(20, 20, 0, 0, 0);
							infoPanelBgSizer.Add(infoPanelBgTC, 1, wx.Alignment.wxALIGN_CENTER_VERTICAL);
						}
						colourSizer.Add(infoPanelBgSizer, 0, wx.Stretch.wxEXPAND);
					}
					boxSizer.Add(colourSizer, 0, wx.Stretch.wxEXPAND);

					fontSizer = new wx.StaticBoxSizer(fontBox, wx.Orientation.wxVERTICAL);
					{
						contactListFontSizer = new wx.StaticBoxSizer(contactListFontBox, wx.Orientation.wxHORIZONTAL);
						{
							contactListFontSizer.Add(contactListFontCheck, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							contactListFontSizer.Add(20, 20, 0, 0, 0);
							contactListFontSizer.Add(contactListFontButton, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							contactListFontSizer.Add(20, 20, 0, 0, 0);
							contactListFontSizer.Add(contactListFontTC, 1, wx.Alignment.wxALIGN_CENTER_VERTICAL);
						}
						fontSizer.Add(contactListFontSizer, 0, wx.Stretch.wxEXPAND);

						infoPanelFontSizer = new wx.StaticBoxSizer(infoPanelFontBox, wx.Orientation.wxHORIZONTAL);
						{
							infoPanelFontSizer.Add(infoPanelFontCheck, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							infoPanelFontSizer.Add(20, 20, 0, 0, 0);
							infoPanelFontSizer.Add(infoPanelFontButton, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							infoPanelFontSizer.Add(20, 20, 0, 0, 0);
							infoPanelFontSizer.Add(infoPanelFontTC, 1, wx.Alignment.wxALIGN_CENTER_VERTICAL);
						}
						fontSizer.Add(infoPanelFontSizer, 0, wx.Stretch.wxEXPAND);

						topChatFontSizer = new wx.StaticBoxSizer(topChatFontBox, wx.Orientation.wxHORIZONTAL);
						{
							topChatFontSizer.Add(topChatFontCheck, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							topChatFontSizer.Add(20, 20, 0, 0, 0);
							topChatFontSizer.Add(topChatFontButton, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							topChatFontSizer.Add(20, 20, 0, 0, 0);
							topChatFontSizer.Add(topChatFontTC, 1, wx.Alignment.wxALIGN_CENTER_VERTICAL);
						}
						fontSizer.Add(topChatFontSizer, 0, wx.Stretch.wxEXPAND);					

						chatEntryFontSizer = new wx.StaticBoxSizer(chatEntryFontBox, wx.Orientation.wxHORIZONTAL);
						{
							chatEntryFontSizer.Add(chatEntryFontCheck, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							chatEntryFontSizer.Add(20, 20, 0, 0, 0);
							chatEntryFontSizer.Add(chatEntryFontButton, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							chatEntryFontSizer.Add(20, 20, 0, 0, 0);
							chatEntryFontSizer.Add(chatEntryFontTC, 1, wx.Alignment.wxALIGN_CENTER_VERTICAL);
						}
						fontSizer.Add(chatEntryFontSizer, 0, wx.Stretch.wxEXPAND);
					}
					boxSizer.Add(fontSizer, 0, wx.Stretch.wxEXPAND|wx.Direction.wxTOP, 5);

					sizeSizer = new wx.StaticBoxSizer(sizeBox, wx.Orientation.wxHORIZONTAL);
					{
						mainWindowSizer = new wx.StaticBoxSizer(mainWindowBox, wx.Orientation.wxVERTICAL);
						{
							mainWindowGrid = new wx.FlexGridSizer(2, 2, 5, 5);
							{
								mainWindowGrid.Add(mainWidthST, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL|
								                   wx.Alignment.wxALIGN_RIGHT);
								mainWindowGrid.Add(mainWidthSpin, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
								mainWindowGrid.Add(mainHeightST, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL|
								                   wx.Alignment.wxALIGN_RIGHT);
								mainWindowGrid.Add(mainHeightSpin, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							}
							mainWindowSizer.Add(mainWindowGrid, 0, wx.Stretch.wxEXPAND);
						}
						sizeSizer.Add(mainWindowSizer, 1, 0);
						

						chatWindowSizer = new wx.StaticBoxSizer(chatWindowBox, wx.Orientation.wxVERTICAL);
						{
							chatWindowGrid = new wx.FlexGridSizer(2, 2, 5, 5);
							{
								chatWindowGrid.Add(chatWidthST, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL|
								                   wx.Alignment.wxALIGN_RIGHT);
								chatWindowGrid.Add(chatWidthSpin, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
								chatWindowGrid.Add(chatHeightST, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL|
								                   wx.Alignment.wxALIGN_RIGHT);
								chatWindowGrid.Add(chatHeightSpin, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL);
							}
							chatWindowSizer.Add(chatWindowGrid, 0, wx.Stretch.wxEXPAND);
						}
						sizeSizer.Add(chatWindowSizer, 1, 0);
						
					}
					boxSizer.Add(sizeSizer, 0, wx.Stretch.wxEXPAND|wx.Direction.wxTOP, 5);
					
					
				}
				topSizer.Add(boxSizer, 0, wx.Stretch.wxEXPAND|wx.Direction.wxALL, 5);
			}
			this.Sizer = topSizer;
			topSizer.SetSizeHints(this);
		}
		
		private void OnContactListBgButtonUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (contactListBgCheck.Value != true)
				e.Enabled = true;
			else
				e.Enabled = false;				
		}
		private void OnInfoPanelBgButtonUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (infoPanelBgCheck.Value != true)
				e.Enabled = true;
			else
				e.Enabled = false;	
		}
		
		private void OnContactListFontButtonUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (contactListFontCheck.Value != true)
				e.Enabled = true;
			else
				e.Enabled = false;	
		}
		
		private void OnInfoPanelFontButtonUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (infoPanelFontCheck.Value != true)
				e.Enabled = true;
			else
				e.Enabled = false;	
		}
		
		private void OnTopChatFontButtonUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (topChatFontCheck.Value != true)
				e.Enabled = true;
			else
				e.Enabled = false;	
		}
		
		private void OnChatEntryFontButtonUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (chatEntryFontCheck.Value != true)
				e.Enabled = true;
			else
				e.Enabled = false;	
		}
		
//		private void OnContactListBgTCUI(object sender, wx.Event evt)
//		{
//			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
//			
//			if (contactListBgCheck.Value != true)
//				contactListBgTC.Show(true);
//			else
//				contactListBgTC.Show(false);
//		}
		
		private void OnContactListFontTCUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (contactListFontCheck.Value != true)
				if (contactListFont is wxGadu.Font)
					e.Text = contactListFont.FaceName + ' ' + contactListFont.Family.ToString() + ' ' + contactListFont.Size;
				else
					e.Text = string.Empty;
			else
				e.Text = string.Empty;
		}
		
		private void OnInfoPanelFontTCUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (infoPanelFontCheck.Value != true)
				if (infoPanelFont is wxGadu.Font)
					e.Text = infoPanelFont.FaceName + ' ' + infoPanelFont.Family.ToString() + ' ' + infoPanelFont.Size;
				else
					e.Text = string.Empty;
			else
				e.Text = string.Empty;
		}
			
		private void OnTopChatFontTCUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (topChatFontCheck.Value != true)
				if (topChatFont is wxGadu.Font)
					e.Text = topChatFont.FaceName + ' ' + topChatFont.Family.ToString() + ' ' + topChatFont.Size;
				else

					e.Text = string.Empty;
			else
				e.Text = string.Empty;
		}
		
		private void OnChatEntryFontTCUI(object sender, wx.Event evt)
		{
			wx.UpdateUIEvent e = (wx.UpdateUIEvent) evt;
			
			if (chatEntryFontCheck.Value != true)
				if (chatEntryFont is wxGadu.Font)
					e.Text = chatEntryFont.FaceName + ' ' + chatEntryFont.Family.ToString() + ' ' + chatEntryFont.Size;
				else
					e.Text = string.Empty;
			else
				e.Text = string.Empty;
		}

		
		public Colour ContactListBgColor
		{
			get { return contactListBgColor; }
			set { contactListBgColor = value; }
		}
		
		public Colour InfoPanelBgColor
		{
			get { return infoPanelBgColor; }
			set { infoPanelBgColor = value; }
		}
		
		public Font ContactListFont
		{
			get { return contactListFont; }
			set { contactListFont = value; }
		}
		
		public Font InfoPanelFont
		{
			get { return infoPanelFont; }
			set { infoPanelFont = value; }
		}
		
		public Font TopChatFont
		{
			get { return topChatFont; }
			set { topChatFont = value; }
		}
		
		public Font ChatEntryFont
		{
			get { return chatEntryFont; }
			set { chatEntryFont = value; }
		}
		
		private void OnContactListBgButton(object sender, wx.Event evt)
		{
			wx.ColourDialog colorDlg = new wx.ColourDialog(this);
			if (colorDlg.ShowModal() == wx.Window.wxID_OK)
			{
				wx.ColourData cd = colorDlg.ColourData;
				contactListBgTC.BackgroundColour = cd.Colour;
				
				contactListBgColor = new Colour(cd.Colour);
			}
		}
		
		private void OnInfoPanelBgButton(object sender, wx.Event evt)
		{
			wx.ColourDialog colorDlg = new wx.ColourDialog(this);
			if (colorDlg.ShowModal() == wx.Window.wxID_OK)
			{
				wx.ColourData cd = colorDlg.ColourData;
				infoPanelBgTC.BackgroundColour = cd.Colour;
				
				infoPanelBgColor = new Colour(cd.Colour);
			}
		}
		private void OnContactListFontButton(object sender, wx.Event evt)
		{
			wx.FontDialog fontDlg = new wx.FontDialog(this);
			
			if (fontDlg.ShowModal() == wx.Window.wxID_OK)
			{
				wx.FontData fd = fontDlg.FontData;
				contactListFontTC.Value = fd.ChosenFont.FaceName + ' ' + fd.ChosenFont.FamilyString + ' ' + fd.ChosenFont.PointSize;
				
				contactListFont = new Font(fd.ChosenFont);
			}
		}
		
		private void OnInfoPanelFontButton(object sender, wx.Event evt)
		{
			wx.FontDialog fontDlg = new wx.FontDialog(this);
			
			if (fontDlg.ShowModal() == wx.Window.wxID_OK)
			{
				wx.FontData fd = fontDlg.FontData;
				infoPanelFontTC.Value = fd.ChosenFont.FaceName + ' ' + fd.ChosenFont.FamilyString + ' ' + fd.ChosenFont.PointSize;
				
				infoPanelFont = new Font(fd.ChosenFont);
			}
		}
		
		private void OnTopChatFontButton(object sender, wx.Event evt)
		{
			wx.FontDialog fontDlg = new wx.FontDialog(this);
			
			if (fontDlg.ShowModal() == wx.Window.wxID_OK)
			{
				wx.FontData fd = fontDlg.FontData;
				topChatFontTC.Value = fd.ChosenFont.FaceName + ' ' + fd.ChosenFont.FamilyString + ' ' + fd.ChosenFont.PointSize;
				
				topChatFont = new Font(fd.ChosenFont);
			}
		}
		
		private void OnChatEntryFontButton(object sender, wx.Event evt)
		{
			wx.FontDialog fontDlg = new wx.FontDialog(this);
			
			if (fontDlg.ShowModal() == wx.Window.wxID_OK)
			{
				wx.FontData fd = fontDlg.FontData;
				chatEntryFontTC.Value = fd.ChosenFont.FaceName + ' ' + fd.ChosenFont.FamilyString + ' ' + fd.ChosenFont.PointSize;
				
				chatEntryFont = new Font(fd.ChosenFont);
			}
		}
		
		public bool ContactListBgCheck
		{
			get { return contactListBgCheck.Value; }
			set { contactListBgCheck.Value = value; }
		}
		
		public bool InfoPanelBgCheck
		{
			get { return infoPanelBgCheck.Value; }
			set { infoPanelBgCheck.Value = value; }
		}
		
		public bool ContactListFontCheck
		{
			get { return contactListFontCheck.Value; }
			set { contactListFontCheck.Value = value; }
		}
		
		public bool InfoPanelFontCheck
		{
			get { return infoPanelFontCheck.Value; }
			set { infoPanelFontCheck.Value = value; }
		}
		
		public bool TopChatFontCheck
		{
			get { return topChatFontCheck.Value; }
			set { topChatFontCheck.Value = value; }
		}
		
		public bool ChatEntryFontCheck
		{
			get { return chatEntryFontCheck.Value; }
			set { chatEntryFontCheck.Value = value; }
		}
		
		public int MainWindowWidth
		{
			get { return mainWidthSpin.Value; }
			
			set 
			{
				if (value > 0)
					mainWidthSpin.Value = value;
				else
				{
#if LOG
					logger.Warn(String.Format(Catalog.GetString("Invalid value: {0}"), value));
#endif
					mainWidthSpin.Value = 100;
				}
			}
		}
		
		public int MainWindowHeight
		{
			get { return mainHeightSpin.Value; }
			
			set 
			{
				if (value > 0)
					mainHeightSpin.Value = value;
				else
				{
#if LOG
					logger.Warn(String.Format(Catalog.GetString("Invalid value: {0}"), value));
#endif
					mainHeightSpin.Value = 200;
				}
			}
		}
		
		public int ChatWindowWidth
		{
			get { return chatWidthSpin.Value; }
			
			set 
			{
				if (value > 0)
					chatWidthSpin.Value = value;
				else
				{
#if LOG
					logger.Warn(String.Format(Catalog.GetString("Invalid value: {0}"), value));
#endif
					chatWidthSpin.Value = 345;
				}
			}
		}
		
		public int ChatWindowHeight
		{
			get { return chatHeightSpin.Value; }
			
			set 
			{
				if (value > 0)
					chatHeightSpin.Value = value;
				else
				{
#if LOG
					logger.Warn(String.Format(Catalog.GetString("Invalid value: {0}"), value));
#endif
					chatHeightSpin.Value = 360;
				}
			}
		}
		
		public wx.Colour ContactListBgTC
		{
			set { contactListBgTC.BackgroundColour = value; }
		}
		
		public wx.Colour InfoPanelBgTC
		{
			set { infoPanelBgTC.BackgroundColour = value; }
		}
		
		public string ContactListFontTC
		{
			set { contactListFontTC.Value = value; }
		}
		
		public string InfoPanelFontTC
		{
			set { infoPanelFontTC.Value = value; }
		}
		
		public string TopChatFontTC
		{
			set { topChatFontTC.Value = value; }
		}
		
		public string ChatEntryFontTC
		{
			set { chatEntryFontTC.Value = value; }
		}
		
		
		
	}
}
